import { defHttp } from "/@/utils/http/axios"
import { Modal } from "ant-design-vue"
import { NamespaceCodeEnum } from '/@/enums/iamEnum'
import { removeRepeatSlashOfUrl } from '/@/utils/index'
import { getBizUrl } from '/@/utils/common/bizUrlUtils'

export const listMenu = (params) => {
  const url = "/iam-service/addonMenu/listMenuTree"
  return defHttp.get({ url, params })
} 

/**
 * 删除菜单
 */
export const deleteMenu = (params, handleSuccess) => {
  return defHttp.delete({ url: "/iam-service/addonMenu/delete", params }, { joinParamsToUrl: true }).then(() => {
    handleSuccess()
  })
}


/**
 * 保存或者更新菜单
 * @param params
 */
export const saveOrUpdateMenu = (params, isUpdate) => {
  const url = isUpdate ? '/iam-service/addonMenu/update' : '/iam-service/addonMenu/save' 
  return defHttp.post({ url, params })
}


/**
 * 根据code获取字典数值
 * @param params
 */
export const ajaxGetDictItems = (params) => defHttp.get({ url: `/infra-service/dictItem/listItem/`, params: { ...params, code: params.code } })

/**
 * 查询所有可用权限
 * @returns
 */
export const listAllPermissionValue = () => defHttp.get({ url: Api.listAllPermissionValue })


export const listWorkspaceMenuTree = (params) => defHttp.get({ url: '/iam-service/menu/listWorkspaceMenuTree' , params})


